/*
 * Copyright 2010,2011 Michael Nitsche
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package de.mnit.basis.sys.event;

import de.mnit.basis.daten.struktur.S_Folge;
import de.mnit.basis.daten.struktur.schluessel.topf.S_SchluesselTopf;
import de.mnit.basis.daten.struktur.schluessel.topf.SchluesselTopf;
import de.mnit.basis.fehler.Fehler;

/** @deprecated **/
public abstract class A_HatZuhoerer<TA> {

	private final S_SchluesselTopf<String,S_Zuhoerer<?>> zuhoerer;


	public A_HatZuhoerer() {
		this.zuhoerer=SchluesselTopf.neu();
	}


	@SuppressWarnings("unchecked")
	protected final TA t = (TA)this;

	protected void zuhoererPlus(String ident, S_Zuhoerer<?> l) {
		Fehler.objekt.wenn_Null(ident, l);
		this.zuhoerer.plus(ident, l);
	}

	protected void zuhoererStart(String ident) {
		zuhoererStart(ident, null);
	}

	@SuppressWarnings("unchecked")
	protected <T1> void zuhoererStart(String ident, T1 daten) {
		Fehler.objekt.wenn_Null(ident);
		S_Folge<S_Zuhoerer<?>> z=this.zuhoerer.gib(ident,null);
		if(z!=null)
			for(S_Zuhoerer<?> l : z) {
				S_Zuhoerer<T1> l2=(S_Zuhoerer<T1>) l; //Wirft ggf. Fehler!
				l2.verarbeite(daten);
			}
	}

}
